package com.learn.framework.repository;

import org.springframework.beans.factory.annotation.Autowired;

import javax.sql.DataSource;
import java.lang.reflect.Field;
import java.sql.Connection;

public abstract class BaseRepository<T> {
    @Autowired
    DataSource dataSource;

    public boolean update(T entity) throws Exception {
        Connection db = dataSource.getConnection();
        String sql = "UPDATE " + entity.getClass().toString() + "";
        Field[] fields = entity.getClass().getDeclaredFields();
        for (Field fieldName : fields) {
            fieldName.setAccessible(true);
            Object value = fieldName.get(entity);
        }
        db.prepareStatement(sql);
        return false;
    }
}
